<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Obaju : e-commerce template</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="robots" content="all,follow">
    <!-- Bootstrap CSS-->
    <link rel="stylesheet" href="sourse/vendor/bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome CSS-->
    <link rel="stylesheet" href="sourse/vendor/font-awesome/css/font-awesome.min.css">
    <!-- Google fonts - Roboto -->
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,700">
    <!-- owl carousel-->
    <link rel="stylesheet" href="sourse/vendor/owl.carousel/assets/owl.carousel.css">
    <link rel="stylesheet" href="sourse/vendor/owl.carousel/assets/owl.theme.default.css">
    <!-- theme stylesheet-->
    <link rel="stylesheet" href="sourse/css/style.default.css" id="theme-stylesheet">
    <!-- Custom stylesheet - for your changes-->
    <link rel="stylesheet" href="sourse/css/custom.css">
    <!-- Favicon-->
    <link rel="shortcut icon" href="favicon.png">
    <!-- Tweaks for older IEs--><!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script><![endif]-->
  </head>
  <body>
    <div id="all">
      <div id="content">
        <div class="container">
          <div class="row">
            <div id="checkout" class="col-lg-9">
              <div class="box">
                <form method="get">
                  <h1>Checkout - Order review</h1>
<%--                  <div class="nav flex-column flex-sm-row nav-pills"><a href="checkout1.html" class="nav-link flex-sm-fill text-sm-center"> <i class="fa fa-map-marker">                  </i>Address</a><a href="checkout2.jsp" class="nav-link flex-sm-fill text-sm-center"> <i class="fa fa-truck">                       </i>Delivery Method</a><a href="checkout3.jsp" class="nav-link flex-sm-fill text-sm-center"> <i class="fa fa-money">                      </i>Payment Method</a><a href="#" class="nav-link flex-sm-fill text-sm-center active"> <i class="fa fa-eye">                     </i>Order Review</a></div>--%>
                  <div class="content">
                    <div class="table-responsive">
                      <table class="table">
                        <thead>
                          <tr>
                            <th colspan="2">商品</th>
                            <th>个数</th>
                            <th>单价</th>
                            <th>折扣</th>
                            <th>总价</th>
                          </tr>
                        </thead>
                        <tbody>
                          <c:forEach items="${orders}" var="order">
                            <tr>
                              <td><a href="javascript:void(0)" onclick="window.parent.location.href = 'goodsDetails?gid=${order.goodsId}'"><img src="${order.goodsImage}"></a></td>
                              <td><a href="javascript:void(0)" onclick="window.parent.location.href = 'goodsDetails?gid=${order.goodsId}'">${order.goodsName}</a></td>
                              <td>${order.goodsNumber}</td>
                              <td>￥${order.goodsPrice}</td>
                              <td>￥${order.goodsPrice*order.goodsDiscount}</td>
                              <td>￥${order.goodsNumber*order.goodsPrice*order.goodsDiscount}</td>
                            </tr>
                          </c:forEach>
                        </tbody>
                        <tfoot>
                          <tr>
                            <th colspan="5">总价</th>
                            <th>￥${newSum}</th>
                          </tr>
                        </tfoot>
                      </table>
                    </div>
                    <!-- /.table-responsive-->
                  </div>
                  <!-- /.content-->
                  <div class="box-footer d-flex justify-content-between">
                    <button type="button" id="jsl" class="btn btn-primary">结算<i class="fa fa-chevron-right"></i></button>
                  </div>
                </form>
              </div>
              <!-- /.box-->
            </div>
            <!-- /.col-lg-9-->
            <div class="col-lg-3">
              <div id="order-summary" class="card">
                <div class="card-header">
                  <h3 class="mt-4 mb-4">订单摘要</h3>
                </div>
                <div class="card-body">
                  <p class="text-muted">按照实际价格计算</p>
                  <div class="table-responsive">
                    <table class="table">
                      <tbody>
                        <tr>
                          <td>实付</td>
                          <th>￥${newSum}</th>
                        </tr>
                        <tr>
                          <td>折扣</td>
                          <th>￥${sum-newSum}</th>
                        </tr>
                        <tr class="total">
                          <td>总价</td>
                          <th>￥${sum}</th>
                        </tr>
                      </tbody>
                    </table>
                  </div>
                </div>
              </div>
            </div>
            <!-- /.col-lg-3-->
          </div>
        </div>
      </div>
    </div>
    <!-- *** COPYRIGHT END ***-->
    <!-- JavaScript files-->
    <script src="sourse/vendor/jquery/jquery.min.js"></script>
    <script src="sourse/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
    <script src="sourse/vendor/jquery.cookie/jquery.cookie.js"> </script>
    <script src="sourse/vendor/owl.carousel/owl.carousel.min.js"></script>
    <script src="sourse/vendor/owl.carousel2.thumbs/owl.carousel2.thumbs.js"></script>
    <script src="sourse/js/front.js"></script>
  <script type="text/javascript">
    $("#jsl").click(function () {
        if($('input[type="radio"]:checked',window.parent.document).length==0){
            alert("请选择地址")
        }else{
            $.ajax({
                type:"post",
                data:{"goods":$("#dz",window.parent.document).attr("name"),"addid":$('input[type="radio"]:checked',window.parent.document).val()},
                url:"settlement",
                success: function (rels) {
                    if(rels!="-1"){
                      alert("添加成功")
                      $("#oid",window.parent.document).attr("name",rels)
                      console.info($("#oid",window.parent.document).attr("name"))
                      console.info(rels)
                      window.parent.ShowDiv('MyDiv','fade')
                    }else{
                        alert("添加失败")
                    }
                }
            })
        }
    })
  </script>
  </body>
</html>